<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<title>edit visit</title>
</h:head>
<body>
	<ui:composition template="/pages/common/commonLayout.xhtml">
		<ui:define name="content">
			<p:panelGrid columns="2">
				<h:outputLabel value="Imie i nazwisko: " />
				<h:outputText value="#{visitMB.chosenPatient.fullName}" />
			</p:panelGrid>
			<h:form>
				<p:panel header="Dostepne wizyty" toggleable="true" widgetVar="panel" closable="false" toggleSpeed="500" closeSpeed="500">
					<p:panelGrid columns="4" header="Nowa wizyta" 
						widgetVar="panel" style="margin-bottom:20px; margin-top:15px;">
						<h:outputLabel for="spec" value="Specjalizacja:" />
						<p:selectOneMenu id="spec" value="#{visitMB.specialization}"
							required="false" update="@form">
							<f:selectItem itemLabel="" itemValue=""/>
							<f:selectItems value="#{enumBean.specializationValues}"
								var="spec" itemValue="#{spec}" itemLabel="#{spec.label}" />
						</p:selectOneMenu>
						<h:outputLabel value="Data od:" />
						<p:calendar value="#{visitMB.dateStart}" mindate="#{visitMB.today}" pattern="MM/dd/yyyy HH:mm"/>
						<h:outputLabel value="Data do:" />
						<p:calendar value="#{visitMB.dateEnd}" mindate="#{visitMB.today}" pattern="MM/dd/yyyy HH:mm"/>
						<h:outputLabel value="Lekarz:" />
						<p:autoComplete id="doctorChosen" multiple="true" value="#{visitMB.doctors}" styleClass="myStyle"
							completeMethod="#{visitMB.doctorToChoose}" var="doctor" itemLabel="#{doctor.fullName}" 
							itemValue="#{doctor}" converter="doctorConverter" forceSelection="false">
				            <p:column>
				                <h:outputText value="#{doctor.fullName}" />
				            </p:column>
				        </p:autoComplete>
						<br/><br/><br/>
						<p:commandButton value="Szukaj" action="#{visitMB.findFreeVisits}" update="@form"/>
					</p:panelGrid>
				</p:panel>
				<p:panel>
					<p:dataTable var="visit" value="#{visitMB.freeVisits}" paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15" rows="10">
						<p:column headerText="Poczatek"> 
							<h:outputText value="#{visit.dateStart}" >
								<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
							</h:outputText>
						</p:column>
						<p:column headerText="Doktor">
							<h:outputText value="#{visit.schedule.doctor.fullName} (#{visit.schedule.doctor.spec})" />
						</p:column>
<!-- 						<p:column headerText="Pacjent"> -->
<!-- 							<h:outputText value="#{visit.patient.fullNameHidden}" /> -->
<!-- 						</p:column> -->
						<p:column headerText="Akcje">
							<p:commandButton icon="ui-icon-plus" value="Umów" action="#{visitMB.chooseVisit}" 
								update="@form" disabled="#{visit.patient ne null}" ajax="true">
								<f:setPropertyActionListener target="#{visitMB.visitToChoose}" value="#{visit}"/>
							</p:commandButton>
						</p:column>
					</p:dataTable>			
				</p:panel>
			</h:form>
		</ui:define>
	</ui:composition>
</body>
</html>
